function ajax_upload(button_id, hidden_input, config_ws, button_response)
{
	var button = $('#'+button_id), interval; 
	new AjaxUpload(button,{
		name: 'myfile',
		data: { type : 'profile' },
		action: config_ws + '/upload.php?hidName='+hidden_input,
		onSubmit : function(file , ext){
			button.text('Uploading'); 
			if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
				// extension is not allowed
				alert('Error: invalid file extension');
				// cancel upload
				return false;
			}
			this.disable(); 
			interval = window.setInterval(function(){
				var text = button.text();
				if (text.length < 13){
					button.text(text + '.');
				} else {
					button.text('Uploading');
				}
			}, 200); 
		},
		onComplete: function(file, response){
			button.text('Upload Again');
			window.clearInterval(interval);
			// enable upload button
			this.enable();
			// add file to the list
			$('#' + button_response).html(response);
		} 
	});		
}